package it.softphone.cmc.maven;

/*
 * Copyright 2001-2005 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import it.softphone.cmc.impl.ScriptletServiceClientImpl;
import it.softphone.cmc.shared.entity.Asset;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;

/**
 * List scriptlet mojo
 * 
 * Goal which touches a timestamp file.
 *
 */
//@MojoRequiresProject(false)
//@MojoGoal("list")
@Mojo(	name="list",
		requiresProject=false,
		threadSafe=true)
public class ScriptletListMojo extends AbstractScriptletQueryMojo
{
	
	//@MojoParameter(expression="${sourceDir}")
	@Parameter(property="sourceDir")
	java.io.File sourceDir;
	
	
	@Override
	public void execute() throws MojoExecutionException, MojoFailureException {
		
		final ScriptletServiceClientImpl service = super.createService();
		
		Asset filter = makeAssetFromParameter(service);
		
		System.out.println( "========================================");
		System.out.println( "> LIST SCRIPTLET");		
		System.out.println();		
		System.out.printf( "> From [%s]\n", getBaseUrl() );		
		System.out.println( "========================================");

		java.util.List<String> keys = service.findScriptletKeys( filter );
				
		for( String k :keys ) {
			
			System.out.println( k );
		}

		System.out.println( "========================================");
	}
}
